package org.dslintegration.history;

import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;

public class MergeHistory {
	protected List<MergeAction> actions = new ArrayList<MergeAction>();
	protected Date creationDate;

	public MergeHistory() {
		creationDate = Calendar.getInstance().getTime();
	}

	public List<MergeAction> getActions() {
		return actions;
	}

	public void setActions(List<MergeAction> actions) {
		this.actions = actions;
	}

	public Date getCreationDate() {
		return creationDate;
	}

	public void setCreationDate(Date creationDate) {
		this.creationDate = creationDate;
	}

	public void append(MergeHistory history) {
		this.actions.addAll(history.getActions());
	}

	public void add(MergeAction action) {
		this.getActions().add(action);
	}

	@Override
	public String toString() {
		StringBuilder builder = new StringBuilder("MergeHistory [creationDate=" + creationDate + "]");
		for (int i = 0; i < actions.size(); i++) {
			builder.append("\n");
			builder.append(i + 1);
			builder.append(",\t");
			builder.append(actions.get(i));
		}
		return builder.toString();
	}
}
